package com.coin.exchange.bitfinex.rest.api.impl;

import com.coin.exchange.bitfinex.rest.api.IPublicRestApi;
import com.coin.exchange.okcoin.rest.HttpUtil;

/**
 * 
 * @author duyuchong
 *
 */
public class PublicRestApiImpl implements IPublicRestApi {

	private String url_prex = "https://api.bitfinex.com";
	
	private final String TICKER_URL = "/v1/pubticker/";
	private final String STATS_URL = "/v1/stats/";
	private final String FUNDINGBOOK_URL = "/v1/lendbook/";
	private final String ORDERBOOK_URL = "/v1/book/";
	private final String TRADES_URL = "/v1/trades/";
	private final String LENDS_URL = "/v1/lends/";
	private final String SYMBOLS_URL = "/v1/symbols";
	private final String SYMBOL_DETAILS_URL = "/v1/symbols_details";

	@Override
	public String getTicker(String symbol) throws Exception {
		String url = url_prex + TICKER_URL + symbol;
		String result = HttpUtil.get(url, null);
		return result;
	}

	@Override
	public String getStats(String symbol) throws Exception {
		String url = url_prex + STATS_URL + symbol;
		String result = HttpUtil.get(url, null);
		return result;
	}

	@Override
	public String getFundingbook(String currency) throws Exception {
		String url = url_prex + FUNDINGBOOK_URL + currency;
		String result = HttpUtil.get(url, null);
		return result;
	}

	@Override
	public String getOrderbook(String symbol) throws Exception {
		String url = url_prex + ORDERBOOK_URL + symbol;
		String result = HttpUtil.get(url, null);
		return result;
	}

	@Override
	public String getTrades(String symbol) throws Exception {
		String url = url_prex + TRADES_URL + symbol;
		String result = HttpUtil.get(url, null);
		return result;
	}

	@Override
	public String getLends(String currency) throws Exception {
		String url = url_prex + LENDS_URL + currency;
		String result = HttpUtil.get(url, null);
		return result;
	}

	@Override
	public String getSymbols() throws Exception {
		String url = url_prex + SYMBOLS_URL;
		String result = HttpUtil.get(url, null);
		return result;
	}

	@Override
	public String getSymbolsDetails() throws Exception {
		String url = url_prex + SYMBOL_DETAILS_URL;
		String result = HttpUtil.get(url, null);
		return result;
	}

}
